. do SelfConstrained 

. ***************************************************************************
. * This program creates the tables and figures for "The Self-Constrained Hand-
> to-Mouth" by Michael Gelman
. * 01/20/2021
. *****************************************************************************
> *
. 
. /*NOTES
> ***************************************************************************
> Software used: Stata version 16 on Linux 
> ****************************************************************************/
. clear

. set more off

. 
. *set global vars
.         global new_base = "~/mgelman/data/SelfConstrained/rep"

.         global fig "fig"

.         global tab "tab"

.         global plot_args vert recast(line) nooffset graphregion(color(white))
>  bgcolor(white) 

.         global plot_opt = "lcolor(black) ciplot(rline) acolor(gray) alpattern
> (dot)" 

.         
. 
. *0000000000000000000000
. *STEP 1: LOAD AND PROCESS ALL OF THE CORE TX DATA FROM SQL
. *0000000000000000000000
.         cap program drop _all

.         *loop through partitions
.         forval i = 0/9 {
  2.                 *define vars
.                         *paycheck
.                                 local paycheck_raw $new_base/raw/paycheck_p`i
> '.tsv
  3.                                 local paycheck_dta $new_base/dta/aux/paych
> eck_p`i'.dta 
  4.                         *expenditures
.                                 local expenditures_raw $new_base/raw/daily_ex
> penditures_p`i'.tsv
  5.                                 local expenditures_dta $new_base/dta/aux/d
> aily_expenditures_p`i'.dta
  6.                         *liquidity
.                                 local liq_raw $new_base/raw/daily_liq_balance
> _`i'.tsv
  7.                                 local daily_liq_dta $new_base/dta/aux/dail
> y_balance_`i'.dta
  8.                         *refund 
.                                 local refund_raw $new_base/raw/refund_`i'.tsv
  9.                                 local refund_dta $new_base/dta/aux/refund_
> `i'.dta
 10.                         *ML files
.                                 local cat_raw $new_base/../../ML/restaurant/o
> ut/rest_type_hat`i'.csv
 11.                                 local cat_dta $new_base/dta/aux/spending_r
> est_hat`i'.dta
 12.                         *merged file
.                                 local merged_dta $new_base/dta/aux/merged_dat
> a_p`i'.dta
 13.                         *payroll schedule file
.                                 local payroll_file $new_base/dta/aux/bi_weekl
> y_strict_by_odd_`i'.dta
 14.                         *processed file
.                                 local after_collapse $new_base/dta/analysis_a
> fter_collapse_`i'.dta 
 15.                 *load liquidity data [rawfile, daily_dtafile, partition]
.                         SQL_data_load "load_liquidity_data" `liq_raw' `daily_
> liq_dta' p`i'
 16.                 *load paycheck date [rawfile, dtafile, partition]
.                         SQL_data_load "load_paycheck_data" `paycheck_raw' `pa
> ycheck_dta' p`i'
 17.                 *load daily expenditures data that takes out CC spending, 
> TX, and selects on sample [rawfile, dtafile]
.                         SQL_data_load "load_expenditures_data" `expenditures_
> raw' `expenditures_dta' p`i'
 18.                 *load refund data [rawfile, dtafile]
.                         SQL_data_load "load_refund_data" `refund_raw' `refund
> _dta' p`i'
 19.                 *load ML data
.                         SQL_data_load "load_cat_data" `cat_raw' `cat_dta'
 20.                 *combine files
.                         SQL_data_load "combine_data" `paycheck_dta' `expendit
> ures_dta' `daily_liq_dta' `cat_dta' `merged_dta'
 21.                 *process combined files
.                         SQL_data_load "process_combined_data" `merged_dta' `p
> ayroll_file' `after_collapse '
 22.         }

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(3 vars, 10,972,793 obs)
(3,360,697 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_balance_0.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance_0.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(5 vars, 255,740 obs)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/paycheck_p0.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p0.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(4 vars, 13,500,588 obs)
(2,169,483 real changes made)
(716,978 real changes made)
       panel variable:  user_int_tmp (unbalanced)
        time variable:  date, 04dec2012 to 31jul2016, but with gaps
                delta:  1 day
user_id:  (1,261,638 real changes made)
(1,261,638 real changes made)
(1,261,638 real changes made)
  variable date was float now int
  variable x was double now long
  variable y was double now long
  (38,282,280 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_expenditures_p0.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expenditures_p0.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(2 vars, 6,249 obs)
(644 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/refund_0.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/refund_0.dta saved
(4 vars, 2,377,749 obs)
(107,341 real changes made)
(1,391,909 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/spending_rest_hat0.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest_hat0.dta saved
Input from ~/mgelman/data/SelfConstrained/rep/../../ML/restaurant/out/rest_type
> _hat0.csv and Output to ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_r
> est_hat0.dta

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p0.dta
                 obs | 3828228
                vars |      4
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p0.d
> ta
                 obs | 255740
                vars |      5
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p0.dta
                 obs | 3828228
                vars |      9  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 3572488  obs only in master data                (code==1
> )
                     | 255740  obs both in master and using data      (code==3)
-------------------------------------------------------------------------------
(0 observations deleted)
(0 observations deleted)
(3,664,184 missing values generated)
(520,064 real changes made)
(2,085,640 real changes made)
(667,803 real changes made)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p0.dta
                 obs | 3828228
                vars |      9
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance
> _0.dta
                 obs | 3392926
                vars |      3  (selection via udrop/ukeep)
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p0.dta
                 obs | 4276247
                vars |     12  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 883321  obs only in master data                (code==1)
                     | 448019  obs only in using data                 (code==2)
                     | 2944907  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(448,019 observations deleted)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p0.dta
                 obs | 3828228
                vars |     10
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest
> _hat0.dta
                 obs | 2377749
                vars |      4
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p0.dta
                 obs | 3828228
                vars |     14  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 1450479  obs only in master data                (code==1
> )
                     | 2377749  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(1,450,479 real changes made)
(1,450,479 real changes made)
  (0 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/merged_data_p0.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p0.dta saved
(91,977 missing values generated)
(36,246 real changes made)
(55,731 observations deleted)

Duplicates in terms of all variables

(63,496 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/bi_weekly_strict_by_odd_0.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_strict_by_odd_0.dta s
> aved
(2,958 real changes made, 2,958 to missing)

-------------------------------------------------------------------------------
merge specs          |
       matching type | n:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 0.dta
                 obs | 3828228
                vars |     12
          match vars | user_id  (not a key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_str
> ict_by_odd_0.dta
                 obs |    927
                vars |      2
          match vars | user_id  (key)
---------------------+---------------------------------------------------------
variable user_id does not uniquely identify observations in the master data
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 0.dta
                 obs | 3828228
                vars |     15  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 2637262  obs only in master data                (code==1
> )
                     | 1190966  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(255,622 real changes made)
(56,127 observations deleted)
(5,362 observations deleted)
  variable week_date was float now int
  variable freq was float now byte
  variable odd was float now byte
  variable x was double now long
  variable y was double now long
  (7,816,608 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> nalysis_after_collapse_0.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/analysis_after_collapse_0.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(3 vars, 28,749,123 obs)
(8,927,270 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_balance_1.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance_1.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(5 vars, 684,996 obs)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/paycheck_p1.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p1.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(4 vars, 36,500,690 obs)
(5,836,174 real changes made)
(1,942,683 real changes made)
       panel variable:  user_int_tmp (unbalanced)
        time variable:  date, 04dec2012 to 31jul2016, but with gaps
                delta:  1 day
user_id:  (3,349,682 real changes made)
(3,349,682 real changes made)
(3,349,682 real changes made)
  variable date was float now int
  variable x was double now long
  variable y was double now long
  (102,409,250 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_expenditures_p1.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expenditures_p1.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(2 vars, 17,219 obs)
(1,815 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/refund_1.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/refund_1.dta saved
(4 vars, 6,390,679 obs)
(285,978 real changes made)
(3,750,926 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/spending_rest_hat1.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest_hat1.dta saved
Input from ~/mgelman/data/SelfConstrained/rep/../../ML/restaurant/out/rest_type
> _hat1.csv and Output to ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_r
> est_hat1.dta

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p1.dta
                 obs | 10240925
                vars |      4
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p1.d
> ta
                 obs | 684996
                vars |      5
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p1.dta
                 obs | 10240925
                vars |      9  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 9555929  obs only in master data                (code==1
> )
                     | 684996  obs both in master and using data      (code==3)
-------------------------------------------------------------------------------
(0 observations deleted)
(0 observations deleted)
(9,818,288 missing values generated)
(1,518,072 real changes made)
(5,514,630 real changes made)
(1,771,383 real changes made)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p1.dta
                 obs | 10240925
                vars |      9
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance
> _1.dta
                 obs | 9072535
                vars |      3  (selection via udrop/ukeep)
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p1.dta
                 obs | 11441390
                vars |     12  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 2368855  obs only in master data                (code==1
> )
                     | 1200465  obs only in using data                 (code==2
> )
                     | 7872070  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(1,200,465 observations deleted)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p1.dta
                 obs | 10240925
                vars |     10
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest
> _hat1.dta
                 obs | 6390679
                vars |      4
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p1.dta
                 obs | 10240925
                vars |     14  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 3850246  obs only in master data                (code==1
> )
                     | 6390679  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(3,850,246 real changes made)
(3,850,246 real changes made)
  (0 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/merged_data_p1.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p1.dta saved
(244,135 missing values generated)
(100,626 real changes made)
(143,509 observations deleted)

Duplicates in terms of all variables

(175,184 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/bi_weekly_strict_by_odd_1.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_strict_by_odd_1.dta s
> aved
(7,903 real changes made, 7,903 to missing)

-------------------------------------------------------------------------------
merge specs          |
       matching type | n:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 1.dta
                 obs | 10240925
                vars |     12
          match vars | user_id  (not a key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_str
> ict_by_odd_1.dta
                 obs |   2534
                vars |      2
          match vars | user_id  (key)
---------------------+---------------------------------------------------------
variable user_id does not uniquely identify observations in the master data
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 1.dta
                 obs | 10240925
                vars |     15  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 6991124  obs only in master data                (code==1
> )
                     | 3249801  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(684,605 real changes made)
(145,704 observations deleted)
(14,388 observations deleted)
  variable week_date was float now int
  variable freq was float now byte
  variable odd was float now byte
  variable x was double now long
  variable y was double now long
  (20,979,056 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> nalysis_after_collapse_1.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/analysis_after_collapse_1.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(3 vars, 11,279,522 obs)
(3,544,562 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_balance_2.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance_2.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(5 vars, 274,643 obs)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/paycheck_p2.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p2.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(4 vars, 14,414,429 obs)
(2,304,260 real changes made)
(776,412 real changes made)
       panel variable:  user_int_tmp (unbalanced)
        time variable:  date, 04dec2012 to 31jul2016, but with gaps
                delta:  1 day
user_id:  (1,342,566 real changes made)
(1,342,566 real changes made)
(1,342,566 real changes made)
  variable date was float now int
  variable x was double now long
  variable y was double now long
  (40,672,390 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_expenditures_p2.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expenditures_p2.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(2 vars, 6,482 obs)
(598 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/refund_2.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/refund_2.dta saved
(4 vars, 2,525,161 obs)
(115,394 real changes made)
(1,469,597 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/spending_rest_hat2.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest_hat2.dta saved
Input from ~/mgelman/data/SelfConstrained/rep/../../ML/restaurant/out/rest_type
> _hat2.csv and Output to ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_r
> est_hat2.dta

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p2.dta
                 obs | 4067239
                vars |      4
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p2.d
> ta
                 obs | 274643
                vars |      5
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p2.dta
                 obs | 4067239
                vars |      9  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 3792596  obs only in master data                (code==1
> )
                     | 274643  obs both in master and using data      (code==3)
-------------------------------------------------------------------------------
(0 observations deleted)
(0 observations deleted)
(3,903,285 missing values generated)
(576,507 real changes made)
(2,134,497 real changes made)
(756,806 real changes made)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p2.dta
                 obs | 4067239
                vars |      9
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance
> _2.dta
                 obs | 3604095
                vars |      3  (selection via udrop/ukeep)
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p2.dta
                 obs | 4546266
                vars |     12  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 942171  obs only in master data                (code==1)
                     | 479027  obs only in using data                 (code==2)
                     | 3125068  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(479,027 observations deleted)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p2.dta
                 obs | 4067239
                vars |     10
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest
> _hat2.dta
                 obs | 2525161
                vars |      4
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p2.dta
                 obs | 4067239
                vars |     14  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 1542078  obs only in master data                (code==1
> )
                     | 2525161  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(1,542,078 real changes made)
(1,542,078 real changes made)
  (0 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/merged_data_p2.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p2.dta saved
(95,270 missing values generated)
(37,009 real changes made)
(58,261 observations deleted)

Duplicates in terms of all variables

(64,498 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/bi_weekly_strict_by_odd_2.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_strict_by_odd_2.dta s
> aved
(3,141 real changes made, 3,141 to missing)

-------------------------------------------------------------------------------
merge specs          |
       matching type | n:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 2.dta
                 obs | 4067239
                vars |     12
          match vars | user_id  (not a key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_str
> ict_by_odd_2.dta
                 obs |    949
                vars |      2
          match vars | user_id  (key)
---------------------+---------------------------------------------------------
variable user_id does not uniquely identify observations in the master data
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 2.dta
                 obs | 4067239
                vars |     15  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 2849755  obs only in master data                (code==1
> )
                     | 1217484  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(274,525 real changes made)
(62,573 observations deleted)
(5,664 observations deleted)
  variable week_date was float now int
  variable freq was float now byte
  variable odd was float now byte
  variable x was double now long
  variable y was double now long
  (8,257,888 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> nalysis_after_collapse_2.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/analysis_after_collapse_2.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(3 vars, 27,787,334 obs)
(8,649,754 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_balance_3.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance_3.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(5 vars, 661,930 obs)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/paycheck_p3.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p3.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(4 vars, 35,306,169 obs)
(5,638,187 real changes made)
(1,861,837 real changes made)
       panel variable:  user_int_tmp (unbalanced)
        time variable:  date, 04dec2012 to 31jul2016, but with gaps
                delta:  1 day
user_id:  (3,262,242 real changes made)
(3,262,242 real changes made)
(3,262,242 real changes made)
  variable date was float now int
  variable x was double now long
  variable y was double now long
  (99,233,670 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_expenditures_p3.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expenditures_p3.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(2 vars, 16,290 obs)
(1,641 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/refund_3.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/refund_3.dta saved
(4 vars, 6,175,845 obs)
(277,587 real changes made)
(3,605,157 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/spending_rest_hat3.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest_hat3.dta saved
Input from ~/mgelman/data/SelfConstrained/rep/../../ML/restaurant/out/rest_type
> _hat3.csv and Output to ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_r
> est_hat3.dta

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p3.dta
                 obs | 9923367
                vars |      4
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p3.d
> ta
                 obs | 661930
                vars |      5
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p3.dta
                 obs | 9923367
                vars |      9  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 9261437  obs only in master data                (code==1
> )
                     | 661930  obs both in master and using data      (code==3)
-------------------------------------------------------------------------------
(0 observations deleted)
(0 observations deleted)
(9,525,981 missing values generated)
(1,467,166 real changes made)
(5,279,084 real changes made)
(1,742,292 real changes made)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p3.dta
                 obs | 9923367
                vars |      9
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance
> _3.dta
                 obs | 8788589
                vars |      3  (selection via udrop/ukeep)
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p3.dta
                 obs | 11085427
                vars |     12  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 2296838  obs only in master data                (code==1
> )
                     | 1162060  obs only in using data                 (code==2
> )
                     | 7626529  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(1,162,060 observations deleted)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p3.dta
                 obs | 9923367
                vars |     10
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest
> _hat3.dta
                 obs | 6175845
                vars |      4
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p3.dta
                 obs | 9923367
                vars |     14  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 3747522  obs only in master data                (code==1
> )
                     | 6175845  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(3,747,522 real changes made)
(3,747,522 real changes made)
  (0 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/merged_data_p3.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p3.dta saved
(232,574 missing values generated)
(91,175 real changes made)
(141,399 observations deleted)

Duplicates in terms of all variables

(160,390 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/bi_weekly_strict_by_odd_3.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_strict_by_odd_3.dta s
> aved
(7,667 real changes made, 7,667 to missing)

-------------------------------------------------------------------------------
merge specs          |
       matching type | n:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 3.dta
                 obs | 9923367
                vars |     12
          match vars | user_id  (not a key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_str
> ict_by_odd_3.dta
                 obs |   2359
                vars |      2
          match vars | user_id  (key)
---------------------+---------------------------------------------------------
variable user_id does not uniquely identify observations in the master data
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 3.dta
                 obs | 9923367
                vars |     15  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 6897728  obs only in master data                (code==1
> )
                     | 3025639  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(661,597 real changes made)
(149,048 observations deleted)
(13,858 observations deleted)
  variable week_date was float now int
  variable freq was float now byte
  variable odd was float now byte
  variable x was double now long
  variable y was double now long
  (20,204,448 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> nalysis_after_collapse_3.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/analysis_after_collapse_3.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(3 vars, 11,865,492 obs)
(3,695,059 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_balance_4.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance_4.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(5 vars, 282,898 obs)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/paycheck_p4.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p4.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(4 vars, 15,131,518 obs)
(2,424,575 real changes made)
(800,229 real changes made)
       panel variable:  user_int_tmp (unbalanced)
        time variable:  date, 04dec2012 to 31jul2016, but with gaps
                delta:  1 day
user_id:  (1,387,149 real changes made)
(1,387,149 real changes made)
(1,387,149 real changes made)
  variable date was float now int
  variable x was double now long
  variable y was double now long
  (42,441,850 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_expenditures_p4.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expenditures_p4.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(2 vars, 6,905 obs)
(680 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/refund_4.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/refund_4.dta saved
(4 vars, 2,649,784 obs)
(120,368 real changes made)
(1,533,266 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/spending_rest_hat4.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest_hat4.dta saved
Input from ~/mgelman/data/SelfConstrained/rep/../../ML/restaurant/out/rest_type
> _hat4.csv and Output to ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_r
> est_hat4.dta

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p4.dta
                 obs | 4244185
                vars |      4
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p4.d
> ta
                 obs | 282898
                vars |      5
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p4.dta
                 obs | 4244185
                vars |      9  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 3961287  obs only in master data                (code==1
> )
                     | 282898  obs both in master and using data      (code==3)
-------------------------------------------------------------------------------
(0 observations deleted)
(0 observations deleted)
(4,054,929 missing values generated)
(613,839 real changes made)
(2,257,639 real changes made)
(742,177 real changes made)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p4.dta
                 obs | 4244185
                vars |      9
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance
> _4.dta
                 obs | 3756213
                vars |      3  (selection via udrop/ukeep)
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p4.dta
                 obs | 4740928
                vars |     12  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 984715  obs only in master data                (code==1)
                     | 496743  obs only in using data                 (code==2)
                     | 3259470  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(496,743 observations deleted)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p4.dta
                 obs | 4244185
                vars |     10
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest
> _hat4.dta
                 obs | 2649784
                vars |      4
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p4.dta
                 obs | 4244185
                vars |     14  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 1594401  obs only in master data                (code==1
> )
                     | 2649784  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(1,594,401 real changes made)
(1,594,401 real changes made)
  (0 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/merged_data_p4.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p4.dta saved
(101,244 missing values generated)
(40,711 real changes made)
(60,533 observations deleted)

Duplicates in terms of all variables

(69,859 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/bi_weekly_strict_by_odd_4.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_strict_by_odd_4.dta s
> aved
(3,290 real changes made, 3,290 to missing)

-------------------------------------------------------------------------------
merge specs          |
       matching type | n:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 4.dta
                 obs | 4244185
                vars |     12
          match vars | user_id  (not a key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_str
> ict_by_odd_4.dta
                 obs |   1013
                vars |      2
          match vars | user_id  (key)
---------------------+---------------------------------------------------------
variable user_id does not uniquely identify observations in the master data
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 4.dta
                 obs | 4244185
                vars |     15  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 2946971  obs only in master data                (code==1
> )
                     | 1297214  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(282,783 real changes made)
(63,401 observations deleted)
(5,934 observations deleted)
  variable week_date was float now int
  variable freq was float now byte
  variable odd was float now byte
  variable x was double now long
  variable y was double now long
  (8,646,768 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> nalysis_after_collapse_4.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/analysis_after_collapse_4.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(3 vars, 16,010,407 obs)
(5,037,341 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_balance_5.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance_5.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(5 vars, 386,763 obs)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/paycheck_p5.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p5.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(4 vars, 20,864,945 obs)
(3,319,566 real changes made)
(1,093,490 real changes made)
       panel variable:  user_int_tmp (unbalanced)
        time variable:  date, 04dec2012 to 31jul2016, but with gaps
                delta:  1 day
user_id:  (1,875,464 real changes made)
(1,875,464 real changes made)
(1,875,464 real changes made)
  variable date was float now int
  variable x was double now long
  variable y was double now long
  (57,830,190 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_expenditures_p5.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expenditures_p5.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(2 vars, 9,532 obs)
(968 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/refund_5.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/refund_5.dta saved
(4 vars, 3,629,201 obs)
(164,025 real changes made)
(2,094,752 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/spending_rest_hat5.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest_hat5.dta saved
Input from ~/mgelman/data/SelfConstrained/rep/../../ML/restaurant/out/rest_type
> _hat5.csv and Output to ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_r
> est_hat5.dta

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p5.dta
                 obs | 5783019
                vars |      4
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p5.d
> ta
                 obs | 386763
                vars |      5
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p5.dta
                 obs | 5783019
                vars |      9  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 5396256  obs only in master data                (code==1
> )
                     | 386763  obs both in master and using data      (code==3)
-------------------------------------------------------------------------------
(0 observations deleted)
(0 observations deleted)
(5,536,736 missing values generated)
(847,816 real changes made)
(3,075,776 real changes made)
(1,019,200 real changes made)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p5.dta
                 obs | 5783019
                vars |      9
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance
> _5.dta
                 obs | 5125049
                vars |      3  (selection via udrop/ukeep)
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p5.dta
                 obs | 6460465
                vars |     12  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 1335416  obs only in master data                (code==1
> )
                     | 677446  obs only in using data                 (code==2)
                     | 4447603  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(677,446 observations deleted)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p5.dta
                 obs | 5783019
                vars |     10
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest
> _hat5.dta
                 obs | 3629201
                vars |      4
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p5.dta
                 obs | 5783019
                vars |     14  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 2153818  obs only in master data                (code==1
> )
                     | 3629201  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(2,153,818 real changes made)
(2,153,818 real changes made)
  (0 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/merged_data_p5.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p5.dta saved
(137,035 missing values generated)
(55,221 real changes made)
(81,814 observations deleted)

Duplicates in terms of all variables

(95,322 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/bi_weekly_strict_by_odd_5.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_strict_by_odd_5.dta s
> aved
(4,472 real changes made, 4,472 to missing)

-------------------------------------------------------------------------------
merge specs          |
       matching type | n:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 5.dta
                 obs | 5783019
                vars |     12
          match vars | user_id  (not a key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_str
> ict_by_odd_5.dta
                 obs |   1372
                vars |      2
          match vars | user_id  (key)
---------------------+---------------------------------------------------------
variable user_id does not uniquely identify observations in the master data
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 5.dta
                 obs | 5783019
                vars |     15  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 4025248  obs only in master data                (code==1
> )
                     | 1757771  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(386,543 real changes made)
(85,334 observations deleted)
(8,094 observations deleted)
  variable week_date was float now int
  variable freq was float now byte
  variable odd was float now byte
  variable x was double now long
  variable y was double now long
  (11,798,832 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> nalysis_after_collapse_5.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/analysis_after_collapse_5.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(3 vars, 12,065,938 obs)
(3,768,783 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_balance_6.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance_6.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(5 vars, 288,490 obs)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/paycheck_p6.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p6.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(4 vars, 15,232,777 obs)
(2,435,883 real changes made)
(801,745 real changes made)
       panel variable:  user_int_tmp (unbalanced)
        time variable:  date, 04dec2012 to 31jul2016, but with gaps
                delta:  1 day
user_id:  (1,421,270 real changes made)
(1,421,270 real changes made)
(1,421,270 real changes made)
  variable date was float now int
  variable x was double now long
  variable y was double now long
  (43,020,480 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_expenditures_p6.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expenditures_p6.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(2 vars, 6,919 obs)
(730 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/refund_6.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/refund_6.dta saved
(4 vars, 2,667,302 obs)
(116,736 real changes made)
(1,570,316 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/spending_rest_hat6.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest_hat6.dta saved
Input from ~/mgelman/data/SelfConstrained/rep/../../ML/restaurant/out/rest_type
> _hat6.csv and Output to ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_r
> est_hat6.dta

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p6.dta
                 obs | 4302048
                vars |      4
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p6.d
> ta
                 obs | 288490
                vars |      5
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p6.dta
                 obs | 4302048
                vars |      9  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 4013558  obs only in master data                (code==1
> )
                     | 288490  obs both in master and using data      (code==3)
-------------------------------------------------------------------------------
(0 observations deleted)
(0 observations deleted)
(4,128,919 missing values generated)
(604,692 real changes made)
(2,294,033 real changes made)
(751,720 real changes made)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p6.dta
                 obs | 4302048
                vars |      9
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance
> _6.dta
                 obs | 3807234
                vars |      3  (selection via udrop/ukeep)
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p6.dta
                 obs | 4809079
                vars |     12  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 1001845  obs only in master data                (code==1
> )
                     | 507031  obs only in using data                 (code==2)
                     | 3300203  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(507,031 observations deleted)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p6.dta
                 obs | 4302048
                vars |     10
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest
> _hat6.dta
                 obs | 2667302
                vars |      4
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p6.dta
                 obs | 4302048
                vars |     14  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 1634746  obs only in master data                (code==1
> )
                     | 2667302  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(1,634,746 real changes made)
(1,634,746 real changes made)
  (0 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/merged_data_p6.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p6.dta saved
(101,473 missing values generated)
(41,097 real changes made)
(60,376 observations deleted)

Duplicates in terms of all variables

(71,010 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/bi_weekly_strict_by_odd_6.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_strict_by_odd_6.dta s
> aved
(3,328 real changes made, 3,328 to missing)

-------------------------------------------------------------------------------
merge specs          |
       matching type | n:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 6.dta
                 obs | 4302048
                vars |     12
          match vars | user_id  (not a key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_str
> ict_by_odd_6.dta
                 obs |   1023
                vars |      2
          match vars | user_id  (key)
---------------------+---------------------------------------------------------
variable user_id does not uniquely identify observations in the master data
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 6.dta
                 obs | 4302048
                vars |     15  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 2991193  obs only in master data                (code==1
> )
                     | 1310855  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(288,391 real changes made)
(68,745 observations deleted)
(5,966 observations deleted)
  variable week_date was float now int
  variable freq was float now byte
  variable odd was float now byte
  variable x was double now long
  variable y was double now long
  (8,693,744 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> nalysis_after_collapse_6.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/analysis_after_collapse_6.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(3 vars, 32,974,294 obs)
(10,187,598 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_balance_7.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance_7.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(5 vars, 788,360 obs)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/paycheck_p7.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p7.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(4 vars, 41,612,537 obs)
(6,649,313 real changes made)
(2,215,585 real changes made)
       panel variable:  user_int_tmp (unbalanced)
        time variable:  date, 04dec2012 to 31jul2016, but with gaps
                delta:  1 day
user_id:  (3,832,829 real changes made)
(3,832,829 real changes made)
(3,832,829 real changes made)
  variable date was float now int
  variable x was double now long
  (70,175,364 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_expenditures_p7.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expenditures_p7.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(2 vars, 19,642 obs)
(2,258 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/refund_7.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/refund_7.dta saved
(4 vars, 7,287,822 obs)
(325,880 real changes made)
(4,261,094 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/spending_rest_hat7.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest_hat7.dta saved
Input from ~/mgelman/data/SelfConstrained/rep/../../ML/restaurant/out/rest_type
> _hat7.csv and Output to ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_r
> est_hat7.dta

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p7.dta
                 obs | 11695894
                vars |      4
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p7.d
> ta
                 obs | 788360
                vars |      5
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p7.dta
                 obs | 11695894
                vars |      9  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 10907534  obs only in master data                (code==
> 1)
                     | 788360  obs both in master and using data      (code==3)
-------------------------------------------------------------------------------
(0 observations deleted)
(0 observations deleted)
(11,218,226 missing values generated)
(1,745,669 real changes made)
(6,213,390 real changes made)
(2,031,640 real changes made)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p7.dta
                 obs | 11695894
                vars |      9
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance
> _7.dta
                 obs | 10351072
                vars |      3  (selection via udrop/ukeep)
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p7.dta
                 obs | 13063142
                vars |     12  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 2712070  obs only in master data                (code==1
> )
                     | 1367248  obs only in using data                 (code==2
> )
                     | 8983824  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(1,367,248 observations deleted)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p7.dta
                 obs | 11695894
                vars |     10
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest
> _hat7.dta
                 obs | 7287822
                vars |      4
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p7.dta
                 obs | 11695894
                vars |     14  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 4408072  obs only in master data                (code==1
> )
                     | 7287822  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(4,408,072 real changes made)
(4,408,072 real changes made)
  (0 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/merged_data_p7.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p7.dta saved
(272,698 missing values generated)
(111,316 real changes made)
(161,382 observations deleted)

Duplicates in terms of all variables

(198,373 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/bi_weekly_strict_by_odd_7.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_strict_by_odd_7.dta s
> aved
(9,036 real changes made, 9,036 to missing)

-------------------------------------------------------------------------------
merge specs          |
       matching type | n:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 7.dta
                 obs | 11695894
                vars |     12
          match vars | user_id  (not a key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_str
> ict_by_odd_7.dta
                 obs |   2861
                vars |      2
          match vars | user_id  (key)
---------------------+---------------------------------------------------------
variable user_id does not uniquely identify observations in the master data
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 7.dta
                 obs | 11695894
                vars |     15  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 8024025  obs only in master data                (code==1
> )
                     | 3671869  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(788,049 real changes made)
(176,359 observations deleted)
(16,324 observations deleted)
  variable week_date was float now int
  variable freq was float now byte
  variable odd was float now byte
  variable x was double now long
  (17,852,760 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> nalysis_after_collapse_7.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/analysis_after_collapse_7.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(3 vars, 11,898,260 obs)
(3,704,749 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_balance_8.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance_8.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(5 vars, 281,669 obs)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/paycheck_p8.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p8.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(4 vars, 14,977,967 obs)
(2,396,937 real changes made)
(799,600 real changes made)
       panel variable:  user_int_tmp (unbalanced)
        time variable:  date, 04dec2012 to 31jul2016, but with gaps
                delta:  1 day
user_id:  (1,397,357 real changes made)
(1,397,357 real changes made)
(1,397,357 real changes made)
  variable date was float now int
  variable x was double now long
  variable y was double now long
  (42,316,330 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_expenditures_p8.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expenditures_p8.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(2 vars, 6,791 obs)
(659 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/refund_8.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/refund_8.dta saved
(4 vars, 2,626,940 obs)
(119,189 real changes made)
(1,532,718 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/spending_rest_hat8.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest_hat8.dta saved
Input from ~/mgelman/data/SelfConstrained/rep/../../ML/restaurant/out/rest_type
> _hat8.csv and Output to ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_r
> est_hat8.dta

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p8.dta
                 obs | 4231633
                vars |      4
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p8.d
> ta
                 obs | 281669
                vars |      5
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p8.dta
                 obs | 4231633
                vars |      9  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 3949964  obs only in master data                (code==1
> )
                     | 281669  obs both in master and using data      (code==3)
-------------------------------------------------------------------------------
(0 observations deleted)
(0 observations deleted)
(4,058,949 missing values generated)
(603,660 real changes made)
(2,292,925 real changes made)
(706,975 real changes made)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p8.dta
                 obs | 4231633
                vars |      9
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance
> _8.dta
                 obs | 3742243
                vars |      3  (selection via udrop/ukeep)
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p8.dta
                 obs | 4726527
                vars |     12  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 984284  obs only in master data                (code==1)
                     | 494894  obs only in using data                 (code==2)
                     | 3247349  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(494,894 observations deleted)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p8.dta
                 obs | 4231633
                vars |     10
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest
> _hat8.dta
                 obs | 2626940
                vars |      4
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p8.dta
                 obs | 4231633
                vars |     14  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 1604693  obs only in master data                (code==1
> )
                     | 2626940  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(1,604,693 real changes made)
(1,604,693 real changes made)
  (0 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/merged_data_p8.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p8.dta saved
(98,237 missing values generated)
(38,243 real changes made)
(59,994 observations deleted)

Duplicates in terms of all variables

(71,306 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/bi_weekly_strict_by_odd_8.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_strict_by_odd_8.dta s
> aved
(3,267 real changes made, 3,267 to missing)

-------------------------------------------------------------------------------
merge specs          |
       matching type | n:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 8.dta
                 obs | 4231633
                vars |     12
          match vars | user_id  (not a key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_str
> ict_by_odd_8.dta
                 obs |   1036
                vars |      2
          match vars | user_id  (key)
---------------------+---------------------------------------------------------
variable user_id does not uniquely identify observations in the master data
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 8.dta
                 obs | 4231633
                vars |     15  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 2902208  obs only in master data                (code==1
> )
                     | 1329425  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(281,526 real changes made)
(65,433 observations deleted)
(5,890 observations deleted)
  variable week_date was float now int
  variable freq was float now byte
  variable odd was float now byte
  variable x was double now long
  variable y was double now long
  (8,586,800 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> nalysis_after_collapse_8.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/analysis_after_collapse_8.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(3 vars, 17,933,553 obs)
(5,562,135 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_balance_9.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance_9.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(5 vars, 425,002 obs)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/paycheck_p9.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p9.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(4 vars, 22,623,220 obs)
(3,625,663 real changes made)
(1,197,907 real changes made)
       panel variable:  user_int_tmp (unbalanced)
        time variable:  date, 04dec2012 to 31jul2016, but with gaps
                delta:  1 day
user_id:  (2,102,089 real changes made)
(2,102,089 real changes made)
(2,102,089 real changes made)
  variable date was float now int
  variable x was double now long
  variable y was double now long
  (63,856,880 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/daily_expenditures_p9.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expenditures_p9.dta saved

mysql: [Warning] Using a password on the command line interface can be insecure
> .
(2 vars, 10,443 obs)
(949 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/refund_9.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/refund_9.dta saved
(4 vars, 3,972,076 obs)
(180,773 real changes made)
(2,314,832 real changes made)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/spending_rest_hat9.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest_hat9.dta saved
Input from ~/mgelman/data/SelfConstrained/rep/../../ML/restaurant/out/rest_type
> _hat9.csv and Output to ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_r
> est_hat9.dta

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p9.dta
                 obs | 6385688
                vars |      4
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/paycheck_p9.d
> ta
                 obs | 425002
                vars |      5
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p9.dta
                 obs | 6385688
                vars |      9  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 5960686  obs only in master data                (code==1
> )
                     | 425002  obs both in master and using data      (code==3)
-------------------------------------------------------------------------------
(0 observations deleted)
(0 observations deleted)
(6,109,614 missing values generated)
(911,280 real changes made)
(3,412,235 real changes made)
(1,073,888 real changes made)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p9.dta
                 obs | 6385688
                vars |      9
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_balance
> _9.dta
                 obs | 5651343
                vars |      3  (selection via udrop/ukeep)
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p9.dta
                 obs | 7134168
                vars |     12  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 1482825  obs only in master data                (code==1
> )
                     | 748480  obs only in using data                 (code==2)
                     | 4902863  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(748,480 observations deleted)

-------------------------------------------------------------------------------
merge specs          |
       matching type | 1:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p9.dta
                 obs | 6385688
                vars |     10
          match vars | user_id date  (key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/spending_rest
> _hat9.dta
                 obs | 3972076
                vars |      4
          match vars | user_id date  (key)
---------------------+---------------------------------------------------------
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/daily_expendi
> tures_p9.dta
                 obs | 6385688
                vars |     14  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 2413612  obs only in master data                (code==1
> )
                     | 3972076  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(2,413,612 real changes made)
(2,413,612 real changes made)
  (0 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/merged_data_p9.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p9.dta saved
(147,514 missing values generated)
(57,440 real changes made)
(90,074 observations deleted)

Duplicates in terms of all variables

(104,639 observations deleted)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/bi_weekly_strict_by_odd_9.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_strict_by_odd_9.dta s
> aved
(4,935 real changes made, 4,935 to missing)

-------------------------------------------------------------------------------
merge specs          |
       matching type | n:1
  mv's on match vars | none
  unmatched obs from | both
---------------------+---------------------------------------------------------
  master        file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 9.dta
                 obs | 6385688
                vars |     12
          match vars | user_id  (not a key)
  -------------------+---------------------------------------------------------
  using         file | ~/mgelman/data/SelfConstrained/rep/dta/aux/bi_weekly_str
> ict_by_odd_9.dta
                 obs |   1559
                vars |      2
          match vars | user_id  (key)
---------------------+---------------------------------------------------------
variable user_id does not uniquely identify observations in the master data
result          file | ~/mgelman/data/SelfConstrained/rep/dta/aux/merged_data_p
> 9.dta
                 obs | 6385688
                vars |     15  (including _merge)
         ------------+---------------------------------------------------------
              _merge | 4388825  obs only in master data                (code==1
> )
                     | 1996863  obs both in master and using data      (code==3
> )
-------------------------------------------------------------------------------
(0 observations deleted)
(424,815 real changes made)
(102,325 observations deleted)
(8,854 observations deleted)
  variable week_date was float now int
  variable freq was float now byte
  variable odd was float now byte
  variable x was double now long
  variable y was double now long
  (12,900,400 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> nalysis_after_collapse_9.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/analysis_after_collapse_9.dta saved

.         *append tax refund data
.                 SQL_data_load "append_data" "$new_base/dta/aux/refund_"
  variable week_date was float now int
  (191,060 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> ux/refund_merged.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/aux/refund_merged.dta saved

.         *append all the processed data
.                 SQL_data_load "append_data" "$new_base/dta/analysis_after_col
> lapse_"
(note: variable y was long, now double to accommodate using data's values)
  (0 bytes saved)
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/a
> nalysis_after_collapse_merged.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/analysis_after_collapse_merged.dta 
> saved

. 
. *0000000000000000000000
. *STEP 2: COMPARITIVE MONTHLY TIME SERIES ANALYSIS (FIG 1)
. *0000000000000000000000
.         *import monthly census data
.         *CENSUS DATA FROM       https://www.census.gov/econ/currentdata/dbsea
> rch?program=MRTS&startYear=2013&endYear=2017&categories=7221&dataType=SM&geoL
> evel=US&notAdjusted=1&submit=GET+DATA&releaseScheduleId=
.                 insheet using ~/Dropbox/git_repo/SelfConstrained/xls/census_d
> ata_ff_rest.csv, clear             
(2 vars, 48 obs)

.                 *create month
.                         ren date date_str

.                         gen date= date(date_str,"MY")

.                         gen mofd = mofd(date)

.                                 format mofd %tm

.                 *delete other vars
.                         drop date_str date

.                 *save down
.                         save $new_base/dta/census_data_ff_rest.dta, replace
(note: file /accounts/projects/ppageonce/mgelman/data/SelfConstrained/rep/dta/c
> ensus_data_ff_rest.dta not found)
file ~/mgelman/data/SelfConstrained/rep/dta/census_data_ff_rest.dta saved

.         
.         *Use data before collapsing and processing
.                 use user_id x_1 date using $new_base/dta/aux/merged_data_p0.d
> ta, clear  

.                         forval i = 1/9{                 
  2.                          append using $new_base/dta/aux/merged_data_p`i'.d
> ta, keep(user_id x_1 date )
  3.                         }

. 
.         *rename the food variable to make it more descriptive
.                 ren x_1 x_food

.                 keep user_id x_food date

.                 gen mofd = mofd(date)

.                         format mofd %tm

.         *sum to the monthly-user level and take logs
.                 collapse (sum) x_food, by(mofd user_id)

.                         gen log_x_food = log(x_food)
(236,578 missing values generated)

.         *drop first and last month
.                 egen min_week = min(mofd), by(user_id)

.                 egen max_week = max(mofd), by(user_id)

.                         drop if inlist(mofd,min_week,max_week)
(100,892 observations deleted)

.         *take monthly average
.                 collapse log_x_food , by(mofd)

.         *merge in census data
.                 qui mmerge mofd using $new_base/dta/census_data_ff_rest.dta, 
> t(1:1)

.                                 keep if _merge == 3
(6 observations deleted)

.                                         drop _merge

.         *create log changes relative to jan 2013
.                 *create log census
.                         gen log_census = ln(census)

.                 *create variable for jan 2013
.                         cap drop jan_app*

.                         foreach type in log_x_food log_census {
  2.                                 gen `type'_tmp = `type' if mofd == tm(2013
> m1)
  3.                                 egen jan_`type' = max(`type'_tmp)
  4.                                         drop `type'_tmp
  5.                                 gen `type'_diff = `type'- jan_`type'
  6.                                 }
(41 missing values generated)
(41 missing values generated)

.         *0000000000000
.         *FIGURE 1: Monthly food expenditures
.         *0000000000000
.                 line *_diff mofd, ///
>                         legend(order(1 "App data" 2 "Census data")) ytitle("L
> og difference relative to Jan 2013") xtitle("Month") graphregion(color(white)
> ) bgcolor(white)  lwidth(thick thick) ///
>                         xlabel(636(6)671, angle(90)) lcolor(black black) lpat
> tern(solid dash)

.                         graph export  $fig/time_series_app_census.eps, replac
> e
(note: file fig/time_series_app_census.eps not found)
(file fig/time_series_app_census.eps written in EPS format)

. 
. *0000000000000000000000
. *STEP 3: DESCRIPTIVE STATS (TABLE 1 AND 2)
. *0000000000000000000000
.         *load data and create variables used in the analysis
.                 *load data
.                         use $new_base/dta/analysis_after_collapse_merged.dta,
>  clear     

.                 *keep relevant vars
.                         keep user_id week_date x x_1 y y_paycheck freq liquid
> _balance odd date

.                 *keep weekly and bi-weekly (drop monthly and semi-monthly)
.                         drop if inlist(freq,1,2)
(1,718,341 observations deleted)

.                 *drop bi-weekly if we don't know the schedule
.                         drop if freq == 3 & mi(odd)
(2,062,305 observations deleted)

.                 *create log food
.                         ren x_1 x_food //rename first to make the var more de
> scriptive

.                         gen log_x_food= log(x_food)                          
>            
(1,256,116 missing values generated)

.                 *set up panel structure
.                         cap drop user_int

.                         egen user_int = group(user_id)

.                         tsset user_int week_date
       panel variable:  user_int (unbalanced)
        time variable:  week_date, 0 to 189
                delta:  1 unit

.                 *create log differences
.                         gen diff_log_x_food = F.log_x_food - log_x_food
(1,716,181 missing values generated)

.                 *create different pay schedule
.                         replace freq = 30 if odd == 0 & freq == 3
(1,559,282 real changes made)

.                         replace freq = 31 if odd == 1 & freq == 3
(1,289,809 real changes made)

.                 *create normalized 2013 liquidity quantile
.                         gen year = year(date)

.                         egen tag = tag(user_int)

.                         *create avg spending and normalized liquidity
.                                 egen x_bar_tmp = mean(x) if year == 2013, by(
> user_id)
(3195934 missing values generated)

.                                         egen x_bar = max(x_bar_tmp), by(user_
> id)

.                                 egen avg_liq_tmp = mean(liquid_balance) if ye
> ar == 2013, by(user_id)
(3201571 missing values generated)

.                                         egen avg_liq_2013 = max(avg_liq_tmp )
> , by(user_id)
(20302 missing values generated)

.                                 gen avg_liquidity_norm = avg_liq_2013 / x_bar
(20,488 missing values generated)

.                                 xtile liq_xtile_tmp = avg_liquidity_norm if t
> ag , nq(3)

.                                         egen liq_xtile = max(liq_xtile_tmp), 
> by(user_int)
(20488 missing values generated)

.                                         drop liq_xtile_tmp

.         *0000000000000
.         *SUMMARY STATS
.         *0000000000000
.                 *create monthly data
.                         preserve

.                         *keep biweekyl paycheck indivdiuals
.                                 keep if inlist(freq,30,31) 
(1,600,777 observations deleted)

.                         *take floor and divide by 7 to get week
.                                 gen month_date = floor(week_date/4)          
>                    

.                 *collapse to the monthly level
.                         collapse (sum) x_food y y_paycheck (mean) liquid_bala
> nce (min) date, by(user_id month_date)                             

.                 *drop min and max week per person
.                         egen min_month = min(month_date), by(user_id)

.                         egen max_month = max(month_date), by(user_id)

.                                 drop if inlist(month_date,min_month,max_month
> )
(31,266 observations deleted)

.                                 drop min_month max_month                

.                 *basic stats (total food income liquid balance) 
.                         foreach type in x x_food y y_paycheck liquid_balance 
>  {                 
  2.                                 cap drop `type'_sumwin
  3.                                 winsor `type' , gen(`type'_sumwin) p(0.01)
  4.                                 }

.                                 
.                         label var x_food_sumwin "Food expenditures ($)"

.                         label var y_sumwin "Income ($)"

.                         label var y_paycheck_sumwin "Paycheck income ($)"

.                         label var liquid_balance_sumwin "Liquid balance ($)"

.                         
.                         qui estpost sum x_food_sumwin y_sumwin y_paycheck_sum
> win liquid_balance_sumwin , det            

.                 *000000000000000000000000000000000000000000000000000
.                 *TABLE 2: SUMMARY STATS
.                 *000000000000000000000000000000000000000000000000000
.                         esttab using "$tab/summary_stats.tex", cells("mean(fm
> t(%9.0fc)) p25(fmt(%9.0fc)) p50(fmt(%9.0fc)) p75(fmt(%9.0fc))") substitute(_ 
> \_ $ \\$) label nonum noobs replace ///
>                                 postfoot(\hline \end{tabular}})
(note: file tab/summary_stats.tex not found)
(output written to tab/summary_stats.tex)

.                         distinct user_id

         |        Observations
         |      total   distinct
---------+----------------------
 user_id |     688071      15633

.                         restore

.                 
.         *00000000000000000000000000
.         *PAYCHECK SHARE ANALYSIS
.         *00000000000000000000000000
.                 *create pay week
.                         gen odd_week = mod(week_date,2) 

.                         cap drop pay_week

.                                 gen pay_week = odd_week

.                                 replace pay_week = 1 - odd_week if freq == 30
>    
(1,559,282 real changes made)

.                                 replace pay_week =0 if !inlist(freq,30,31)
(798,739 real changes made)

.                 *create winsorized versions of income
.                         foreach var in y y_paycheck {
  2.                                 winsor `var', p(0.01) gen(`var'_win)
  3.                                 }

.                 *indv level avg y
.                         egen y_avg = mean(y_win), by(user_id)

.                         cap drop pay_share

.                                 gen pay_share = y_paycheck_win/y_avg 

.                         cap drop y_no_pay non_pay_share

.                                 gen y_no_pay_win=y_win-y_paycheck_win

.                                 gen non_pay_share = y_no_pay_win/y_avg

.                                 
.                 *000000000000000000000000000000000000000000000000000
.                 *TABLE 1: Income share for bi-weekly paycheck receivers
.                 *000000000000000000000000000000000000000000000000000    
.                         *pay and non pay breakdown
.                                 tabstat pay_share non_pay_share if inlist(fre
> q,30,31), by(pay_week) format(%4.2f)

Summary statistics: mean
  by categories of: pay_week 

pay_week |  pay_sh~e  non_pa~e
---------+--------------------
       0 |      0.03      0.41
       1 |      1.32      0.25
---------+--------------------
   Total |      0.67      0.33
------------------------------

.                         *how many bi weekly users?
.                                 distinct user_id if inlist(freq,30,31)

         |        Observations
         |      total   distinct
---------+----------------------
 user_id |    2849091      15633

.                 *000000000000000000000000000000000000000000000000000
.                 *TABLE A2: Income share for bi-weekly paycheck receivers by p
> ay schedule
.                 *000000000000000000000000000000000000000000000000000    
.                         *pay and non pay breakdown (by schedule)
.                                 tabstat pay_share non_pay_share if freq==31, 
> by(pay_week) format(%4.2f)

Summary statistics: mean
  by categories of: pay_week 

pay_week |  pay_sh~e  non_pa~e
---------+--------------------
       0 |      0.03      0.40
       1 |      1.31      0.26
---------+--------------------
   Total |      0.67      0.33
------------------------------

.                                 tabstat pay_share non_pay_share if freq==30, 
> by(pay_week) format(%4.2f)

Summary statistics: mean
  by categories of: pay_week 

pay_week |  pay_sh~e  non_pa~e
---------+--------------------
       0 |      0.02      0.41
       1 |      1.32      0.24
---------+--------------------
   Total |      0.67      0.33
------------------------------

.                                 tab freq if tag

(mean) freq |      Freq.     Percent        Cum.
------------+-----------------------------------
          4 |      8,780       35.96       35.96
         30 |      8,555       35.04       71.01
         31 |      7,078       28.99      100.00
------------+-----------------------------------
      Total |     24,413      100.00

. *0000000000000000000000
. *STEP 4: EXCESS SENSITIVITY TIME SERIES ANALYSIS (FIG 2,3a)
. *0000000000000000000000
.                         
. *00000000000000000000000000000000
. *TIME SERIES PLOTS
. *00000000000000000000000000000000
.         *weekly label
.                         global date_label = ""

.                         local j = 19333

.                         forval i = 0(1)190{
  2.                                 local j = 19333 + 7*`i'
  3.                                 global month = month(`j') 
  4.                                 global day = day(`j') 
  5.                                 global year = year(`j') 
  6.                                 global date_str = "$month/$day/$year"
  7.                                         if mod(`i',4)==0 {
  8.                                                 global date_label = `"`i'.
> week_date = $date_str"' +  `" $date_label"'
  9.                                                 }
 10.                                         *else if mod(`i',4)!=0{
.                                         else {
 11.                                                 global date_label = `"`i'.
> week_date = `" "'"' + `" $date_label"'
 12.                                         }
 13.                                 }                       

.         *000000000000000000000000000000000000000000000000000
.         *FIGURE 2: WEEKLY FOOD EXPENDITURES
.         *000000000000000000000000000000000000000000000000000
.                 gen month = mofd(date)

.                 winsor x_food, gen(x_food_win) p(0.01)

. 
.                 preserve

.                         keep if month >= tm(2014m3) &  month <=tm(2014m9)
(3,717,478 observations deleted)

.                                 qui reg x_food_win ibn.week_date if freq == 3
> 1 , noconst 

.                                         est store odd

.                                 qui reg x_food_win ibn.week_date if freq == 3
> 0 , noconst 

.                                         est store even

.                                 qui reg x_food_win ibn.week_date if freq == 4
> , noconst 

.                                         est store weekly

.                         coefplot (odd, label(Bi-weekly paycheck: Odd schedule
> ) lwidth(thick) lp(dash) lcolor(black) ) ///
>                         (even, label(Bi-weekly paycheck: Even schedule) lwidt
> h(thick) lp(shortdash) lcolor(black)) ///
>                         (weekly, label(Weekly paycheck) lp(solid) lwidth(thic
> k) lcolor(black)),  ///
>                         noci  $plot_args xlabel(,angle(90) notick ) coeflabel
> ($date_label)  ytitle("Food expenditures (weekly)")  legend(rows(3))

.                                 graph export  $fig/weekly_spending.eps, repla
> ce
(note: file fig/weekly_spending.eps not found)
(file fig/weekly_spending.eps written in EPS format)

.                 restore 

.         *000000000000000000000000000000000000000000000000000
.         *FIGURE 3: WEEKLY TIME SERIES FOR BI-WEEKLY PAYCHECK RECEIVERS (HETER
> OGENEITY)
.         *000000000000000000000000000000000000000000000000000
.                 preserve

.                         *KEEP MARCH TO SEPTEMBER 2014
.                                 keep if month >= tm(2014m3) &  month <=tm(201
> 4m9)
(3,717,478 observations deleted)

.                         *AVERAGE ACROSS INDIVIDUALS BY LIQ TERCILE
.                                 collapse (min) date (mean) x_food_win if freq
>  == 31, by(week_date liq_xtile) 

.                                         drop if mi(liq_xtile)
(30 observations deleted)

.                                 reshape wide x_food_win , i(week_date) j(liq_
> xtile)
(note: j = 1 2 3)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                       90   ->      30
Number of variables                   4   ->       5
j variable (3 values)         liq_xtile   ->   (dropped)
xij variables:
                             x_food_win   ->   x_food_win1 x_food_win2 x_food_w
> in3
-----------------------------------------------------------------------------

.                         *CALCUALTE LOG DEVIATIONS
.                                 forval i = 1/3 {
  2.                                                 gen lx_food`i' = log(x_foo
> d_win`i')
  3.                                                 egen mean`i' = mean(lx_foo
> d`i')
  4.                                                 gen dm`i' = lx_food`i' - m
> ean`i'
  5.                                         }

.                         *PLOT THE TIME SERIES
.                                 line dm* date, xlabel(,angle(90)) xtitle("") 
>  legend(cols(3)) lwidth(thick thick thick) lcolor(b b b)  lpattern(solid dash
>  shortdash ) ///
>                                         legend(order(1 "Low liquidity" 2 "Med
> ium liquidity" 3 "High liquidity")) graphregion(color(white)) bgcolor(white) 
> ytitle("Log deviations")  ylabel(-0.15(0.05)0.15)
(note:  named style b not found in class color, default attributes used)
(note:  named style b not found in class color, default attributes used)
(note:  named style b not found in class color, default attributes used)
(note:  named style b not found in class color, default attributes used)
(note:  named style b not found in class color, default attributes used)
(note:  named style b not found in class color, default attributes used)

.                                         graph export  $fig/weekly_spending_li
> q.eps, replace
(note: file fig/weekly_spending_liq.eps not found)
(file fig/weekly_spending_liq.eps written in EPS format)

.                 restore

.                 
. *0000000000000000000000
. *STEP 5: IMPACT OF PAYROLL SCHEDULE (TABLE 3 AND 4)
. *0000000000000000000000
.         *create even week and label
.                 gen even_week = 1-odd_week

.                         label var even_week "$ Even_{it} $"

.                         
.                         cap drop pay_even pay_odd

.                         gen pay_even = pay_week

.                                 replace pay_even = 0 if freq!=30
(643,482 real changes made)

.                         gen pay_odd = pay_week

.                                 replace pay_odd = 0 if freq!=31
(781,217 real changes made)

.         *label variables
.                 label var log_x_food "$ ln(Food_{it}) $"

.                 label var even_week "$ Even_{t} $"

.                 label var pay_even "$ Payweek^{Even}_{it} $"

.                 label var pay_odd "$ Payweek^{Odd}_{it} $"

.                 label var pay_week "$ Payweek_{it} $"

. 
.         *000000000000000000000000000000000000000000000000000
.         *TABLE 3: EXCESS SENSITIVITY ESTIMATES
.         *000000000000000000000000000000000000000000000000000
.                 *baseline reg [broken down into bi-weekly schedule] (column 1
>  of table 3)
.                         qui areg log_x_food even_week pay_even pay_odd, a(use
> r_id) robust cluster(user_id)

.                                 test pay_even = pay_odd

 ( 1)  pay_even - pay_odd = 0

       F(  1, 24388) =    0.08
            Prob > F =    0.7709

.                                 outreg2 using $tab/excess_sensitivity.tex, no
> cons tex(frag) dec(3) replace label nonotes
tab/excess_sensitivity.tex
dir : seeout

.                 *pooled baseline reg (column 2 of table 3)
.                         qui areg log_x_food even_week pay_week, a(user_id) ro
> bust cluster(user_id)      

.                                 outreg2 using $tab/excess_sensitivity.tex, no
> cons tex(frag) dec(3) label  nonotes               
tab/excess_sensitivity.tex
dir : seeout

.         *000000000000000000000000000000000000000000000000000
.         *TABLE 4: EXCESS SENSITIVITY ESTIMATES BY LIQUIDITY TERCILE
.         *000000000000000000000000000000000000000000000000000            
.         *baseline reg with liquidity breakdown (only use 2014 and after data)
.         preserve

.                 keep if year>=2014
(1,337,094 observations deleted)

.                         qui areg log_x_food even_week pay_even pay_odd if liq
> _xtile==1, a(user_id) robust cluster(user_id)

.                                 outreg2 using $tab/excess_sensitivity_liq.tex
> , nocons tex(frag) dec(3) replace label ctitle(Low avg liquidity) nonotes
tab/excess_sensitivity_liq.tex
dir : seeout

.                         qui areg log_x_food even_week pay_even pay_odd if liq
> _xtile==2, a(user_id) robust cluster(user_id)

.                                 outreg2 using $tab/excess_sensitivity_liq.tex
> , nocons tex(frag) dec(3) label ctitle(Medium avg liquidity) nonotes
tab/excess_sensitivity_liq.tex
dir : seeout

.                         qui areg log_x_food even_week pay_even pay_odd if liq
> _xtile==3, a(user_id) robust cluster(user_id)

.                                 outreg2 using $tab/excess_sensitivity_liq.tex
> , nocons tex(frag) dec(3) label ctitle(High avg liquidity) nonotes
tab/excess_sensitivity_liq.tex
dir : seeout

.         restore

. 
. *0000000000000000000000
. *STEP 6: EULER EQUATION TEST (FIGURE 5,7) (TABLE 6)
. *0000000000000000000000
.         *set up panel and create log liquidity
.                 tsset user_int week_date                
       panel variable:  user_int (unbalanced)
        time variable:  week_date, 0 to 189
                delta:  1 unit

.                 gen log_liq = log(L.liquid_balance)     
(884,185 missing values generated)

. 
.         *000000000000000000000000000000000000000000000000000
.         *FIGURE 5: EULER EQUATION TEST (PAY WEEK)
.         *000000000000000000000000000000000000000000000000000
.         *residuals conditional on that pay period
.                 qui areg log_liq if pay_week == 1 & year>=2014 , a(user_int)

.                         predict log_liq_resid_pay, resid
(3,487,444 missing values generated)

.         *plot
.                 preserve

.                 keep if year>=2014 & inlist(freq,30,31)
(2,457,317 observations deleted)

.                 
.                 tw (lpolyci diff_log_x_food log_liq_resid_pay if log_liq_resi
> d_pay >= -2 & log_liq_resid_pay <=2 & pay_week == 1 & liq_xtile == 1, lwidth(
> thick)  $plot_opt )  ///
>                 (lpolyci diff_log_x_food log_liq_resid_pay if log_liq_resid_p
> ay >= -2 & log_liq_resid_pay <=2 & pay_week == 1 & liq_xtile == 2, lpattern(d
> ash) lwidth(thick) $plot_opt) ///
>                 (lpolyci diff_log_x_food log_liq_resid_pay if log_liq_resid_p
> ay >= -2 & log_liq_resid_pay <=2 & pay_week == 1 & liq_xtile == 3, lpattern(s
> hortdash) lwidth(thick) $plot_opt) , ///
>                                 legend(order(2 "Low average liquidity" 4 "Med
> ium average liquidity" 6 "High average liquidity")) ytitle("Food expenditures
>  growth") xtitle("Relative liquidity") ///
>                                 graphregion(color(white)) bgcolor(white) ylab
> el(0.1(0.1)-0.2, angle(360)) 

.                                 graph export  $fig/gc_pay_liq_xtile.eps, repl
> ace        
(note: file fig/gc_pay_liq_xtile.eps not found)
(file fig/gc_pay_liq_xtile.eps written in EPS format)

.                 restore

.         *000000000000000000000000000000000000000000000000000
.         *FIGURE 7: EULER EQUATION TEST (NON PAY WEEK)
.         *000000000000000000000000000000000000000000000000000
.         *residuals conditional on that pay period
.                 qui areg log_liq if pay_week == 0 & year>=2014 , a(user_int)

.                 cap drop log_liq_resid_nopay

.                 predict log_liq_resid_nopay, resid
(2,395,332 missing values generated)

.         *plot
.                 preserve

.                 keep if year>=2014  & inlist(freq,30,31)
(2,457,317 observations deleted)

.                 
.                 tw (lpolyci diff_log_x_food log_liq_resid_nopay if log_liq_re
> sid_nopay >= -2 & log_liq_resid_nopay <= 2 & pay_week == 0 & liq_xtile == 1, 
> lwidth(thick) $plot_opt )  ///
>                    (lpolyci diff_log_x_food log_liq_resid_nopay if log_liq_re
> sid_nopay >= -2 & log_liq_resid_nopay <= 2 & pay_week == 0 & liq_xtile == 2, 
> lpattern(dash) lwidth(thick) $plot_opt) ///
>                    (lpolyci diff_log_x_food log_liq_resid_nopay if log_liq_re
> sid_nopay >= -2 & log_liq_resid_nopay <= 2 & pay_week == 0 & liq_xtile == 3, 
> lpattern(shortdash) lwidth(thick) $plot_opt) , ///
>                                 legend(order(2 "Low average liquidity" 4 "Med
> ium average liquidity" 6 "High average liquidity")) ytitle("Food expenditures
>  growth") xtitle("Relative liquidity") ///
>                                 graphregion(color(white)) bgcolor(white) ylab
> el(-0.1(0.1)0.2, angle(360)) 

.                                         graph export  $fig/gc_nopay_liq_xtile
> .eps, replace
(note: file fig/gc_nopay_liq_xtile.eps not found)
(file fig/gc_nopay_liq_xtile.eps written in EPS format)

.                 restore

.         *000000000000000000000000000000
.         *REGRESSION OUTPUT
.         *000000000000000000000000000000
.                 gen log_liq_pay = log_liq
(884,185 missing values generated)

.                         replace log_liq_pay = 0 if pay_week==0
(3,023,437 real changes made)

.                 gen log_liq_nopay = log_liq
(884,185 missing values generated)

.                         replace log_liq_nopay = 0 if pay_week==1
(1,423,738 real changes made)

.                 label var log_liq_pay "Pay week"

.                 label var log_liq_nopay "Non pay week"

.                 
.                 preserve

.                 keep if year>=2014 & inlist(freq,30,31)
(2,457,317 observations deleted)

.                         qui reghdfe diff_log_x_food  log_liq_pay log_liq_nopa
> y  if year>=2014 & liq_xtile==1, a(user_int#pay_week) vce(cluster user_int)

.                                 outreg2 using $tab/gc_by_liq.tex, nocons tex(
> frag) dec(3) replace label ctitle(Low avg liquidity) nonotes
tab/gc_by_liq.tex
dir : seeout

.                         qui reghdfe diff_log_x_food  log_liq_pay log_liq_nopa
> y  if year>=2014 & liq_xtile==2, a(user_int#pay_week) vce(cluster user_int)

.                                 outreg2 using $tab/gc_by_liq.tex, nocons tex(
> frag) dec(3) label ctitle(Medium avg liquidity) nonotes
tab/gc_by_liq.tex
dir : seeout

.                         qui reghdfe diff_log_x_food  log_liq_pay log_liq_nopa
> y  if year>=2014 & liq_xtile==3, a(user_int#pay_week) vce(cluster user_int)

.                                 outreg2 using $tab/gc_by_liq.tex, nocons tex(
> frag) dec(3) label ctitle(High avg liquidity) nonotes
tab/gc_by_liq.tex
dir : seeout

.                 restore

. 
. *0000000000000000000000
. *STEP 7: EFFECT OF REFUND (FIGURE 10,11,A.2) (TABLE 7,8)
. *0000000000000000000000
.         *0000000000000000
.         *Add in tax refunds
.         *0000000000000000
.                 qui mmerge user_id week_date using $new_base/dta/aux/refund_m
> erged, t(1:1)

.                         drop if _merge == 2 
(49,210 observations deleted)

.                 gen refund_week = _merge == 3

.         *000000000000000000000000000000000000000000000000000
.         *FIGURE A2: CONSUMPTION RESPONSE
.         *000000000000000000000000000000000000000000000000000
.         *IRF
.                 tsset user_int week_date
       panel variable:  user_int (unbalanced)
        time variable:  week_date, 0 to 189
                delta:  1 unit

.                 cap drop IRF 

.                 gen IRF = 0 if !mi(refund_week)

.         
.                 forval i = 1/10 {
  2.                         replace IRF =  `i' if L`i'.refund_week==1 
  3.                         replace IRF =  -`i' if F`i'.refund_week==1
  4.                 }       
(46,264 real changes made)
(46,239 real changes made)
(46,152 real changes made)
(46,144 real changes made)
(45,753 real changes made)
(46,061 real changes made)
(45,452 real changes made)
(45,965 real changes made)
(45,241 real changes made)
(45,852 real changes made)
(45,062 real changes made)
(45,761 real changes made)
(44,862 real changes made)
(45,665 real changes made)
(44,631 real changes made)
(45,506 real changes made)
(44,346 real changes made)
(44,844 real changes made)
(44,055 real changes made)
(43,643 real changes made)

.         
.                 *create IRF variable with no negative values
.                         cap drop IRF2

.                         gen IRF2 = IRF + 10

.         *label
.         global day_label = ""

.         forval i = 0(1)22{
  2.                 local j = `i' - 10
  3.                                 global day_label = `"`i'.IRF2 = `j'"' +  `
> " $day_label"'
  4.                 }

.                 di "$day_label"
22.IRF2 = 12 21.IRF2 = 11 20.IRF2 = 10 19.IRF2 = 9 18.IRF2 = 8 17.IRF2 = 7 16.I
> RF2 = 6 15.IRF2 = 5 14.IRF2 = 4 13.IRF2 = 3 12.IRF2 = 2 11.IRF2 = 1 10.IRF2 =
>  0 9.IRF2 = -1 8.IRF2 = -2 7.IRF2 = -3 6.IRF2 = -4 5.IRF2 = -5 4.IRF2 = -6 3.
> IRF2 = -7 2.IRF2 = -8 1.IRF2 = -9 0.IRF2 = -10 

.         
.         *create figure  
.                 qui areg log_x_food i.week_date ib10.IRF2  , a(user_int) robu
> st cluster(user_int)

.                         coefplot , keep(*IRF2*)  vertical recast(connected)  
> omit base  ///
>                                                 graphregion(color(white)) bgc
> olor(white)   nooffset  mcolor(black) lcolor(black) ciopts(recast(rline) lpat
> tern(dash) lcolor(gray))  ///
>                                                 ytitle("Spending response") x
> title("Weeks since Tax Refund") ///
>                                                 coeflabel($day_label) ylabel(
> 0(0.02)0.14) 

.                                                 graph export  $fig/food_refun
> d_IRF.eps, replace 
(note: file fig/food_refund_IRF.eps not found)
(file fig/food_refund_IRF.eps written in EPS format)

. 
. /*Note: Tax refunds tend to arrive on Mo,Tu,We with the peak on We. 
>         Given that I define the paycheck to start on Thursday, the above figu
> re shows that the impact of the tax refund tends to show up in the week after
>  the refund is received. 
>                 This is just an artifact of the way I define the start of the
>  week. In order to align the two concepts, I use a one period lag for the tax
>  refund indicator.
> */
.                                                 
. *create/label vars
.         cap gen refund_ind = L.refund_week

.                 label var refund_ind "$ refund_{it} $"

.         cap gen refund_ind_pay = refund_ind 

.         replace refund_ind_pay = 0 if pay_week==0
(47,079 real changes made)

.                 label var refund_ind_pay "$ refund_{it} \times payweek_{it} $
> "

.         label var pay_week "$ payweek_{it} $"

.         label var diff_log_x_food "$ \Delta ln(food_{it+1}) $"

. 
. *000000000000000000000000000000000000000000000000000
. *TABLE 7: IMPACT OF REFUND RECEIPT ON EXPENDITURE GROWTH
. *000000000000000000000000000000000000000000000000000
. *only analyze biweekly paycheck receivers
. keep if inlist(freq,30,31)
(1,600,777 observations deleted)

.         qui areg diff_log_x_food refund_ind pay_week refund_ind_pay  if year>
> =2014 & liq_xtile==1, a(user_int)

.                 outreg2 using $tab/gc_by_ref_liq.tex, nocons tex(frag) dec(3)
>  replace label ctitle(Low avg liquidity) nonotes
tab/gc_by_ref_liq.tex
dir : seeout

.         qui areg diff_log_x_food refund_ind pay_week refund_ind_pay  if year>
> =2014 & liq_xtile==2, a(user_int)

.                 outreg2 using $tab/gc_by_ref_liq.tex, nocons tex(frag) dec(3)
>  label ctitle(Medium avg liquidity) nonotes
tab/gc_by_ref_liq.tex
dir : seeout

.         qui areg diff_log_x_food refund_ind pay_week refund_ind_pay  if year>
> =2014 & liq_xtile==3, a(user_int)

.                 outreg2 using $tab/gc_by_ref_liq.tex, nocons tex(frag) dec(3)
>  label ctitle(High avg liquidity) nonotes
tab/gc_by_ref_liq.tex
dir : seeout

. 
. tsset user_int week_date
       panel variable:  user_int (unbalanced)
        time variable:  week_date, 0 to 189
                delta:  1 unit

. *000000000000000000000000000000000000000000000000000
. *FIGURE 10: EULER EQUATION TEST (NON PAY WEEK)
. *000000000000000000000000000000000000000000000000000
.         tw (lpolyci diff_log_x_food log_liq_resid_nopay if log_liq_resid_nopa
> y >= -2 & log_liq_resid_nopay <=2 & pay_week == 0, lwidth(thick) $plot_opt ) 
> ///
>         (lpolyci diff_log_x_food log_liq_resid_nopay if log_liq_resid_nopay >
> = -2 & log_liq_resid_nopay <=2 & pay_week == 0 & refund_ind==1, lwidth(thick)
>  lpattern(dash) $plot_opt ),  ///
>                 legend(order(2 "No tax refund" 4 "Tax refund")) ytitle("Food 
> expenditures growth") xtitle("Relative liquidity") graphregion(color(white)) 
> bgcolor(white) /// 
>                         ylabel(-0.2(0.05)0.2, angle(360)) 

.                 graph export  $fig/gc_nopay_TR.eps, replace     
(note: file fig/gc_nopay_TR.eps not found)
(file fig/gc_nopay_TR.eps written in EPS format)

. *000000000000000000000000000000000000000000000000000
. *FIGURE 11: EULER EQUATION TEST (PAY WEEK)
. *000000000000000000000000000000000000000000000000000
.         tw (lpolyci diff_log_x_food log_liq_resid_pay if log_liq_resid_pay >=
>  -2 & log_liq_resid_pay <=2 & pay_week == 1, lwidth(thick) $plot_opt ) ///
>         (lpolyci diff_log_x_food log_liq_resid_pay if log_liq_resid_pay >= -2
>  & log_liq_resid_pay <=2 & pay_week == 1 & refund_ind==1, lwidth(thick) lpatt
> ern(dash) $plot_opt ),  ///
>                 legend(order(2 "No tax refund" 4 "Tax refund")) ytitle("Food 
> expenditures growth") xtitle("Relative liquidity") graphregion(color(white)) 
> bgcolor(white) /// 
>                         ylabel(-0.2(0.05)0.2, angle(360)) 

.                 graph export  $fig/gc_pay_TR.eps, replace       
(note: file fig/gc_pay_TR.eps not found)
(file fig/gc_pay_TR.eps written in EPS format)

. *000000000000000000000000000000000000000000000000000
. *TABLE 8: EULER EQUATION TEST RESULTS
. *000000000000000000000000000000000000000000000000000
.         *create liquidity variables
.                 gen log_liq_pay_ref2 = log_liq_pay
(288,290 missing values generated)

.                         replace log_liq_pay_ref2 = 0 if refund_ind == 0
(1,400,144 real changes made)

.                 gen log_liq_nopay_ref2 = log_liq_nopay
(280,743 missing values generated)

.                         replace log_liq_nopay_ref2 = 0 if refund_ind == 0
(1,401,743 real changes made)

.         *define labels
.                 label var log_liq_pay "$ liq^{pay}_{it-1} $"

.                 label var log_liq_nopay "$ liq^{nopay}_{it-1} $"

.                 label var log_liq_pay_ref2 "$ liq^{pay}_{it-1} \times refund_
> {it} $"

.                 label var log_liq_nopay_ref2 "$ liq^{nopay}_{it-1} \times ref
> und_{it} $"

.         *estimate the specification and output table
.                 qui reghdfe diff_log_x_food log_liq_pay log_liq_pay_ref2 log_
> liq_nopay log_liq_nopay_ref2 refund_ind refund_ind_pay, a(user_int#pay_week) 
> vce(cluster user_int)

.                                         outreg2 using $tab/gc_by_ref.tex, noc
> ons tex(frag) dec(3) replace label nonotes
tab/gc_by_ref.tex
dir : seeout

.         *test the significance of beta_3 + beta_4
.                 lincom log_liq_nopay + log_liq_nopay_ref2

 ( 1)  log_liq_nopay + log_liq_nopay_ref2 = 0

------------------------------------------------------------------------------
diff_log_x~d |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .0116133   .0090659     1.28   0.200    -.0061569    .0293835
------------------------------------------------------------------------------

. 
end of do-file
